<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2019/9/2
 * Time: 15:51
 */
namespace app\apiteacher\controller;
use think\Db;
class  Bank extends Base {
    /**
     * 异地登录验证
     * @return string
     */
    public function __construct()
    {
        $user_id2 = input('user_id');
        $time = input('time');
        $value = input('value');
        $reqKey = input('reqKey');
        $auth = $this->checkAll($user_id2,$time,$value,$reqKey);
        if($auth == 112){
            echo json_encode(['status'=>301,'msg'=>$this->otherLogin]);
            exit;
        }elseif($auth == 110){
            echo json_encode(['status' => 302, 'msg' => $this->frost]);
            exit;
        }elseif($auth == 2111){
            echo json_encode(['status' => 303, 'msg' => $this->del]);
            exit;
        }
    }
    //列表
    public function index(){
        $page = input('param.page')?input('param.page'):1;
        $subject_id = input('param.subject_id');
        $num = 10;
        $limit = $page-1;
        $where['question_subject_id'] = $subject_id;
        $where['question_status'] = 1;
        $res = Db::table('up_question_bank')->where($where)
            ->limit($num*$limit,$num)
            ->select();
        return json(['status' => 200, 'msg' => $res]);
    }
    //详情
    public function detail(){
        extract(input());
        $id = input('param.id');
        $where['question_id'] = $id;
        $res = Db::table('up_question_bank')->where($where)
            ->find();
        $info = Db::table('up_question_file')->where('q_question_id',$id)->select();
        $res['info'] = $info;
        return json(['status' => 200, 'msg' => $res]);
    }
}